import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    // 全局变量数据，仓库
    state: {
        BuildingList: ['1#', '2#', '3#', '4#', '5#', '6#', '7#', '8#', '9#', '10#', '11#', '12#', '13#', 
            '14#', '15#', '16#', '17#', '18#', '19#', '20#', '21#', '22#', '23#', '24#', '25#'],
        FloorList: {
            "1#": [1,2,3,4,5,6],
            "2#": [1,2,3,4,5,6],
            "3#": [1,2,3,4,5,6],
            "4#": [1,2,3,4,5,6],
            "5#": [1,2,3,4,5,6],
            "6#": [1,2,3,4,5,6],
            "7#": [1,2,3,4,5,6],
            "8#": [1,2,3,4,5,6],
            "9#": [1,2,3,4,5,6,7,8,9],
            "10#": [1,2,3,4,5,6,7,8,9],
            "11#": [1,2,3,4,5,6,7,8,9],
            "12#": [1,2,3,4,5,6,7,8,9],
            "13#": [1,2,3,4,5,6,7,8,9],
            "14#": [1,2,3,4,5,6,7,8,9],
            "15#": [1,2,3,4,5,6,7,8,9,10,11,12],
            "16#": [1,2,3,4,5,6,7,8,9,10,11,12],
            "17#": [1,2,3,4,5,6,7,8,9,10,11,12],
            "18#": [1,2,3,4,5,6,7,8,9,10,11,12],
            "19#": [1,2,3,4,5,6,7,8,9,10,11,12],
            "20#": [1,2,3,4,5,6,7,8,9,10,11,12],
            "21#": [1,2,3,4,5,6,7,8,9,10,11,12],
            "22#": [1,2,3,4,5,6,7,8,9,10,11,12],
            "23#": [1,2,3,4,5,6,7,8,9,10,11,12],
            "24#": [1,2,3,4,5,6,7,8,9,10,11,12],
        },
        // 请求
        requestsList: []
    },
    // 设置state数据的方法
    mutations: {
        addRequestList(state, payload) {
            if(payload === 0){
                // 强行中断时才向下执行
                state.requestsList.forEach( item => {
                    item("interrupt") // 中断请求
                })
                state.requestsList = []
            }else{
                state.requestsList.push(payload)
            }
        }
    },
    // 获取后台接口，并调用mutations提供的方法
    actions: {
        async removeEventListener(ctx) {
            ctx.commit("addRequestList", 0)
        }
    },
    modules: {}
})